package com.lab.es.demo.controller;

import com.lab.es.demo.common.Res;
import com.lab.es.demo.common.ResFactory;
import com.lab.es.demo.common.ResPaging;
import com.lab.es.demo.dto.SearchItemDTO;
import com.lab.es.demo.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
public class ItemController {
    @Autowired
    private ItemService itemService;

    @PostMapping("/search")
    public Res search(@RequestBody(required = true) SearchItemDTO searchItemDTO) throws IOException {
        ResPaging resPaging = itemService.searchPageHighlight(searchItemDTO);
        Res res = ResFactory.getInstance().getEmptyRes();
        res.setData(resPaging);
        res.setCode(100);
        res.setMessage("ok");
        return res;
    }

}
